//
//  LoadGoodsVC.m
//  NtoccShipper
//
//  Created by mac on 2019/12/19.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "LoadGoodsVC.h"
#import "HDPicModle.h"
#import "GetPhoto.h"
#import "OrderListDetailModel.h"
#import "FlexCollectionView.h"
#import "UpLoadCollectionViewCell.h"
#import "UploadImgModel.h"
#import "CJDateTime.h"
#import "XLImageViewer.h"
/**  高德地图  **/
//#import <MAMapKit/MAMapKit.h>
//#import <MAMapKit/MAMapView.h>
//#import <AMapSearchKit/AMapSearchKit.h>
//#import <AMapFoundationKit/AMapFoundationKit.h>
#import <AMapLocationKit/AMapLocationKit.h>

@interface LoadGoodsVC ()<UICollectionViewDelegate,
UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,AMapLocationManagerDelegate>
@property (nonatomic,strong) CJTextField *fieldLoadWeight;
@property (nonatomic,strong) CJTextField *fieldLoadCarNums;
//@property (nonatomic,strong) CJTextField *fieldLoadGoodsTime;
@property (nonatomic,assign) BOOL isChangeReturnOrderImg; // 是否更改
@property (nonatomic,strong) CJLabel *labLoadGoodsImgIndex;
@property (nonatomic,strong) CJLabel *labLoadTypeName;

@property (nonatomic,strong) AMapLocationManager *locationManager;
@property (nonatomic,copy) NSString *strLatitudeMap; // 地图获取过来的
@property (nonatomic,copy) NSString *strLongitudeMap;
@property (nonatomic,copy) NSString *strAddress;

@property (nonatomic,strong) CJLabel *labLodaWeight;
@property (nonatomic,strong) CJLabel *labLoadNums;
@property (nonatomic,strong) UIView *viewNums;//
//@property (nonatomic,strong) UIView *viewLineNums;
@property (nonatomic,strong) UIView *viewTop;

@property (nonatomic,strong) OrderListDetailModel *model;
@property (nonatomic,strong) UICollectionView *collectionView;
@property (nonatomic,strong) NSMutableArray *arrModel;
@property (nonatomic,strong) CJButton *btnSave;
@end
static NSString* reuseCellIdentifier = @"UpLoadCollectionViewCell";

@implementation LoadGoodsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    if (self.isAgain) {
        [self setTitleName:CJLString(@"重新装货")];

    }else{
        [self setTitleName:CJLString(@"装货")];

    }
//    [self setBackLeftButton:@""];
//
    [self initLocationManager];
//    [self loadData];

    [self setBackLeftButton:@""];
    self.view.backgroundColor = [UIColor cjWhiteColor];
    self.arrModel = [[NSMutableArray alloc]init];
    
    for (int i = 0; i < 3; i++) {
        UploadImgModel *model = [[UploadImgModel alloc]init];
        model.strImgUrl = @"";
        model.strTitle = @"";
        model.changeImg = NO;
        model.hideDeleteImg = YES;
        [self.arrModel addObject:model];
    }

//    [self.collectionView reloadData];
    [self loadData];
}

- (void)loadData{
    WS(ws);
//    self.strIsReceiptReturn = @"0";
//    self.strIsAbnormal = @"1";
    [CJNetWork getSourcesOrderListDetailDataWithCode:self.strCode Success:^(id  _Nullable responseObject) {
        
        DLog(@"====== %@",responseObject);
        ws.model = (OrderListDetailModel *)responseObject;
        [ws createTableView];
        [ws setFieldLimit];
    }];
}

//- (void)btnSelectloadGoodsAction{
//    [self.view endEditing:NO];
//    WS(ws);
//    BRDatePickerView *datePickerView = [[BRDatePickerView alloc]initWithPickerMode:BRDatePickerModeYMDHM];
//    datePickerView.title =  @"请选择装车时间 ";
//    datePickerView.minDate = [NSDate br_setYear:2016 month:5 day:1];
//    datePickerView.maxDate = [NSDate br_setYear:2050 month:5 day:1];
//    datePickerView.resultBlock = ^(NSString *selectValue) {
//
//        ws.fieldLoadGoodsTime.text = CJStringWithFormat(@"%@:00",selectValue);
//    };
//
//    BRPickerStyle *customStyle = [BRPickerStyle pickerStyleWithThemeColor:[UIColor cjMainColor]];
//    datePickerView.pickerStyle = customStyle;
//    [datePickerView show];
//
//}

- (void)setFieldLimit{
    self.fieldLoadWeight.textFieldType = CJTextFieldStringTypeThreeDecimalPlaces;
    self.fieldLoadWeight.maxLength = 16;
}

/// 货物数鲁是否三位小数
/// @param isYes <#isYes description#>
- (void)setfieldLoadCarNumsThreeDecimalPlace:(BOOL )isYes{
    
    if (isYes) {
        self.fieldLoadCarNums.textFieldType = CJTextFieldStringTypeThreeDecimalPlaces;
        self.fieldLoadCarNums.maxLength = 16;
    }else{
        self.fieldLoadCarNums.textFieldType = CJTextFieldStringTypeNumber;
        self.fieldLoadCarNums.maxLength = 20;
    }
}

- (void)btnSaveInfoAction{
//    [CJAlert showStringDismissWithDelay:@"隐私协议"];
    
    if ([CJRegular getIsStrEmpty:self.fieldLoadWeight.text]) {
        [[[AFViewShaker alloc] initWithView:self.fieldLoadWeight] shakeWithDuration:[ShakerTime floatValue] completion:^{
            [CJAlert showStringDismissWithDelay:@"请填写装车吨位"];
            
        }];
    }
//    else if ([CJRegular getIsStrEmpty:self.fieldLoadGoodsTime.text]){
//        [[[AFViewShaker alloc] initWithView:self.fieldLoadGoodsTime] shakeWithDuration:[ShakerTime floatValue] completion:^{
//            [CJAlert showStringDismissWithDelay:@"请选择装车时间"];
//
//        }];
//    }
    else{
        
        
//        if (self.arrReturnOrder.count <= 2) {
//            [CJAlert showStringDismissWithDelay:@"最少需要上传3张图片"];
//            return;
//        }
        
        
//        NSMutableArray *arrImgs = [self getArrImgsWitHArrModel:self.arrModel];
         
//         if ([CJControl getIsEmpty:arrImgs[0]]) {
//             [CJAlert showStringDismissWithDelay:@"请上传人车合照片"];
//             return;
//         }
//         if ([CJControl getIsEmpty:arrImgs[1]]) {
//             [CJAlert showStringDismissWithDelay:@"请上传装货交接单"];
//             return;
//         }
//
//         if ([self getArrImgsWitHArrModel:self.arrModel].count <= 3) {
//             [CJAlert showStringDismissWithDelay:@"最少需要上传3张图片"];
//             return;
//         }
//
        __block NSString *strImgs = @"";
        if ([self getArrImgsWitHArrModel:self.arrModel].count > 0) {
            [[self getArrImgsWitHArrModel:self.arrModel] enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                if (idx == 0) {
                    strImgs = obj;
                }else{
                    strImgs = CJStringWithFormat(@"%@,%@",strImgs,obj);
                }
            }];
        }
        
        NSString *strURL = CJStringWithFormat(@"%@/ntocc-tms-api/orderDetail/fill",CJBaseUrl);
        NSDictionary *dicPar;
        OrderModel *orderModel = self.model.order;

        //只输入吨位 weight，向后台传weight，quantity不用
        if (orderModel.coalUnit.intValue == 0) {
            dicPar = @{
            @"code":self.strCode,
            @"imgUrl":strImgs,
            @"weight":self.fieldLoadWeight.text,
            @"time":[CJDateTime getCurrentTimesType:CJDateTimeModeYMDHMS] , //self.fieldLoadGoodsTime.text,
            @"longitude":self.strLongitudeMap,
            @"latitude":self.strLatitudeMap,
//            @"quantity":self.fieldLoadCarNums.text
            };
        }else{
            
            if ([CJRegular getIsStrEmpty:self.fieldLoadCarNums.text]) {
                [[[AFViewShaker alloc] initWithView:self.fieldLoadCarNums] shakeWithDuration:[ShakerTime floatValue] completion:^{
                    [CJAlert showStringDismissWithDelay:@"请填写装车数量"];
                }];
                return;
            }
            
            dicPar = @{
            @"code":self.strCode,
            @"imgUrl":strImgs,
            @"weight":self.fieldLoadWeight.text,
            @"time":[CJDateTime getCurrentTimesType:CJDateTimeModeYMDHMS] , //self.fieldLoadGoodsTime.text,
            @"longitude":self.strLongitudeMap,
            @"latitude":self.strLatitudeMap,
            @"quantity":self.fieldLoadCarNums.text
             };
        }
        
        DLog(@"====== %@",dicPar);
        WS(ws);
        [[HDNetworking sharedHDNetworking] PUT:strURL parameters:dicPar success:^(id  _Nonnull responseObject) {
            DLog(@"====== %@",responseObject);

            if (ws.isAgain) {
                if (ws.blockSucessAgain) {
                    ws.blockSucessAgain(@"");
                }
            }else{
                if (ws.blcokSucess) {
                    ws.blcokSucess(@"");
                }

            }
            [ws pop];
        } failure:^(NSError * _Nonnull error) {
            DLog(@"++++++++%@",error);

        }];
    }
}

/// 创建tableview 等
- (void)createTableView{
    
    //    WS(ws);
    CGRect rcFrame = CGRectMake(0, kTopHeight, [[UIScreen mainScreen] bounds].size.width, 0);
   FlexFrameView *header = [[FlexFrameView alloc] initWithFlex:@"LoadGoodsHeaderView" Frame:rcFrame Owner:self];
    header.flexibleHeight = YES;

    if (self.isAgain) {
        self.labLoadTypeName.text = @"重新装货";
    }else{
        self.labLoadTypeName.text = @"装货";
    }

    // coalUnit(货物单位 0：吨 1：立方米，2-件)
   OrderModel *orderModel = self.model.order;
    if (orderModel.coalUnit.intValue == 0) {
        self.viewNums.hidden = YES;
//        self.viewLineNums.hidden = YES;
//        self.labLodaWeight.text = @"装车吨位(吨)";
        self.labLoadNums.text = @"装车数量(吨)";
        self.viewTop.height = 90;
        [self setfieldLoadCarNumsThreeDecimalPlace:YES];
    }else{
        self.viewNums.hidden = NO;
//        self.viewLineNums.hidden = NO;
        self.viewTop.height = 130;

        if (orderModel.coalUnit.intValue == 1) {
//            self.labLodaWeight.text = @"装车吨位(方)";
            self.labLoadNums.text = @"装车数量(方)";
            [self setfieldLoadCarNumsThreeDecimalPlace:YES];
        }else{
//            self.labLodaWeight.text = @"装车吨位(件)";
            self.labLoadNums.text = @"装车数量(件)";
            [self setfieldLoadCarNumsThreeDecimalPlace:NO];
        }
    }

    // 重新装货赋值
    OrderDetailModel *orderDetailMod = self.model.orderDetail;
    
    if (self.isAgain) {
        
        self.fieldLoadWeight.text = @(orderDetailMod.loadWeight).cj_description;
        self.fieldLoadCarNums.text = @(orderDetailMod.loadQuantity).cj_description;
        
        // 装货图片赋值
        NSArray *imgList = self.model.fillImageInfoList;
        
        if (imgList.count > 0) {

            for (int i = 0; i < imgList.count; i++) {
                
                NSString *strImgUrl = imgList[i];
                if (i == 0 || i == 1 || i == 2) {
                    UploadImgModel *model = self.arrModel[i];
                    model.strImgUrl = strImgUrl;
                    if ([strImgUrl isEqualToString:@""]) {
                        model.hideDeleteImg = YES;
                        model.changeImg = NO;
                    }else{
                        model.hideDeleteImg = NO;
                        model.changeImg = YES;
                    }
                    [self.arrModel replaceObjectAtIndex:i withObject:model];
                }else{
                    UploadImgModel *model = [[UploadImgModel alloc]init];
                    model.strImgUrl = strImgUrl;
                    model.strTitle = @"";
                    model.changeImg = YES;
                    model.hideDeleteImg = NO;
                    [self.arrModel addObject:model];
                }

            }
//             图片数量不足9张 加一个添加图片的部分
            if (self.arrModel.count < 10 && imgList.count > 2) {
                UploadImgModel *model = [[UploadImgModel alloc]init];
                model.strImgUrl = @"";
                model.strTitle = @"";
                model.changeImg = NO;
                model.hideDeleteImg = YES;
                [self.arrModel addObject:model];
            }
        }
    }
    
    [header layoutIfNeeded];

    [self.view addSubview:header];
    [self.view addSubview:self.collectionView];

    self.collectionView.frame = CGRectMake(10, kTopHeight + header.height, kScreenWidth -20, kScreenHeight - kTopHeight - header.height -50);

    if (!_btnSave) {
        _btnSave = CJButton.btnInit
        .btnFrame(CGRectMake(0,self.collectionView.bottom,kScreenWidth, 50))
        .btnBgColor([UIColor cjMainColor])
        .btnTargetAction(self, @selector(btnSaveInfoAction))
        .btnText(self.isAgain ? @"重新装货":@"装货")
        ;
    }
    [self.view addSubview:_btnSave];
    [self.collectionView reloadData];
//
//    self.tableView.tableHeaderView = header;
//    [self.tableView reloadData];
}

#pragma mark collectionView代理方法
//返回section个数
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

//每个section的item个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    if (self.arrModel.count >= 10) {
        return 9;
    }else{
        return self.arrModel.count;
    }
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    UpLoadCollectionViewCell *cell = (UpLoadCollectionViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:reuseCellIdentifier forIndexPath:indexPath];
    
    UploadImgModel *model = self.arrModel[indexPath.row];
    [cell setCellWithModel:model index:indexPath.row arrSum:self.arrModel.count isXieHuo:NO];
    WS(ws);
    cell.blockDelete = ^(id anyObject) {
        [ws btnActionDelecteImgWithIndex:indexPath];
    };
    return cell;
}

- (void)btnActionDelecteImgWithIndex:(NSIndexPath *)indexPath{
    
    // 如果删除前是2个
    if (indexPath.row <= 1) {
        UploadImgModel *model = self.arrModel[indexPath.row];
        model.strImgUrl = @"";
        model.hideDeleteImg = YES;
        model.changeImg = NO;
        [self.arrModel replaceObjectAtIndex:indexPath.row withObject:model];
    }else{
        [self.arrModel removeObjectAtIndex:indexPath.row];
    }
    [self.collectionView reloadData];
}

//设置每个item的尺寸
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake(80, 80);
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
//    NSLog(@"selected: %d",(int)indexPath.row);
    UploadImgModel *modInfo = self.arrModel[indexPath.row];
    
    if (modInfo.changeImg) {
        [self selelctChangeImgVOrSeeBigPicWitnIndex:indexPath.row isLast:NO];
    }else{

//        if (self.arrModel.count == 10) {
//            DLog(@"========")
//            [CJAlert showStringDismissWithDelay:@"最多只能上传9张图片"];
//            return;
//        }
        if (indexPath.row + 1 == self.arrModel.count) {
            UploadImgModel *model = [[UploadImgModel alloc]init];

            model.changeImg = NO;
            [self.arrModel addObject:model];
            DLog(@"===== 点击最后一个");
        }
        [self btnUploadImgVWitnIndex:indexPath.row isLast:NO];
//        }
    }
}

//设置每个item水平间距
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return 20;
}

//设置每个item垂直间距
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 15;
}

- (void)selelctChangeImgVOrSeeBigPicWitnIndex:(NSInteger )index isLast:(BOOL)isLast{
    
    WS(ws);
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
    UIAlertAction *change = [UIAlertAction actionWithTitle:@"更换照片" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        [ws uploadImgV];
        [ws btnUploadImgVWitnIndex:index isLast:isLast];
    }];
    UIAlertAction *seeBig = [UIAlertAction actionWithTitle:@"查看大图" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [[XLImageViewer shareInstanse] showNetImages:[ws getArrImgsWitHArrModel:self.arrModel] index:index fromImageContainer:ws.view];
    }];
    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [alertVC dismissViewControllerAnimated:NO completion:^{
    
        }];
    }];

    [alertVC addAction:change];
    [alertVC addAction:seeBig];
    [alertVC addAction:cancle];
    [self presentViewController:alertVC animated:YES completion:nil];
    
}

// 上传图片
- (void)btnUploadImgVWitnIndex:(NSInteger )index isLast:(BOOL)isLast{
    
    WS(ws);
    [GetPhoto getPhoto:self completion:^(UIImage *curImage, NSData *imageData) {


//        // 计算图片的size
//        CGSize imageSize = CGSizeMake(curImage.size.width, curImage.size.height);
//        // 开启图片类型的图形上下文
//        UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
//        // 绘制图片
//        [curImage drawAtPoint:CGPointZero];
//        // 水印的文字
//        NSString *str = @"水印文字";
//        // 绘制文字水印
//        [str drawAtPoint:CGPointMake(30, 30) withAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20], NSForegroundColorAttributeName:[UIColor redColor]}];
//        // 取图片
//        curImage = UIGraphicsGetImageFromCurrentImageContext();
//        // 关闭图片类型的图形上下文
//        UIGraphicsEndImageContext();
////        UIImageWriteToSavedPhotosAlbum(curImage, NULL, NULL, NULL);
//        [CJControl addWatermarkToPicture:curImage withLoaction:self.strAddress];
//        [ws upLoadReturnImageUImage:[CJControl watermardImageWithImage:curImage text:self.strAddress watermardScale:1] withNSData:imageData withIndex:index isLast:isLast];
        
        [ws upLoadReturnImageUImage:[CJControl watermardImageWithImage:curImage text:CJStringWithFormat(@"经纬度 %@ %@\n%@",[CJControl getThreeUnaryValueStr:ws.strLatitudeMap],[CJControl getThreeUnaryValueStr:ws.strLongitudeMap],[CJControl getThreeUnaryValueStr:ws.strAddress]) watermardScale:1] withNSData:imageData withIndex:index isLast:isLast];
    }];
}

- (void)upLoadReturnImageUImage:(UIImage *)img withNSData:(NSData *)imageData withIndex:(NSInteger )index isLast:(BOOL)isLast{

    NSString *strURL = CJStringWithFormat(@"%@/ntocc-tps-api/fileUpload",CJBaseUrl);
    NSURL *str = [[NSURL alloc]initFileURLWithPath:[CJControl getImgFilePath:img]];
    NSDictionary *dic = @{
                          @"file":str
                          };
    HDPicModle *model = [[HDPicModle alloc]init];
    model.pic = img;
    model.picData = imageData;
    model.picName = @"file";
    model.fileName = [CJControl getImgFilePath:img];

    WS(ws);
    [[HDNetworking sharedHDNetworking] POST:strURL parameters:dic andPic:model progress:^(NSProgress * _Nullable progress) {
//        DLog(@"%lf", 1.0 * progress.completedUnitCount / progress.totalUnitCount);
    } success:^(id  _Nonnull responseObject) {

        NSString *strStatus = CJStringWithFormat(@"%@",responseObject[@"status"]);
        NSString *strImgVUrl = [CJControl getThreeUnaryValueStr:responseObject[@"data"]];

        if (strStatus.integerValue == 0) {
            UploadImgModel *model = ws.arrModel[index];
            model.strImgUrl = strImgVUrl;
            model.changeImg = YES;
            model.hideDeleteImg = NO;
            [ws.arrModel replaceObjectAtIndex:index withObject:model];

        }

        [self.collectionView reloadData];

    } failure:^(NSError * _Nonnull error) {
        DLog(@"+++++++%@",error);

    }];
}

- (NSMutableArray *)getArrImgsWitHArrModel:(NSMutableArray *)arr{
    
    NSMutableArray *arrImgs = [[NSMutableArray alloc]init];
    NSUInteger y ;
    if (arr.count >9) {
        y = 9;
    }else{
        y = arr.count;
    }
    for (int i = 0; i < y; i++) {
        UploadImgModel *model = arr[i];
        [arrImgs addObject:[CJControl getThreeUnaryValueStr:model.strImgUrl]];
    }
    return arrImgs;
}

- (UICollectionView *)collectionView{
    
    if (!_collectionView) {
        
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        _collectionView =[[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
        _collectionView.frame = CGRectMake(10, kTopHeight, kScreenWidth -20, kScreenHeight - kTopHeight);
        [_collectionView registerClass:UpLoadCollectionViewCell.class forCellWithReuseIdentifier:reuseCellIdentifier];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.backgroundColor = [UIColor cjWhiteColor];
        
//        [_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeaderwithReuseIdentifier:@"header"];
        
    }
    return _collectionView;
}

#pragma mark ----------地图相关-----

- (void)initLocationManager{
    
    self.strAddress = @"";
    self.strLatitudeMap = @"";
    self.strLongitudeMap = @"";
    
    self.locationManager = [[AMapLocationManager alloc] init];
    self.locationManager.delegate = self;
    //设置定位最小更新距离方法
    self.locationManager.distanceFilter = 200;
    //指定单次定位超时时间
    self.locationManager.locationTimeout = 20;
    //设置逆地理超时时间
    [self.locationManager setReGeocodeTimeout:20];
    //持续定位是否返回逆地理信息，默认NO
    self.locationManager.locatingWithReGeocode = YES;
    //开启持续定位
    [self.locationManager startUpdatingLocation];
    
}

- (void)amapLocationManager:(AMapLocationManager *)manager didUpdateLocation:(CLLocation *)location reGeocode:(AMapLocationReGeocode *)reGeocode{
    
    DLog(@"location:{lat:%f; lon:%f;} and name is %@", location.coordinate.latitude, location.coordinate.longitude,reGeocode.POIName);
    
    if (IsNilOrNull(reGeocode.POIName)) {
//        [self.locationManager startUpdatingLocation];
//        self.label_address.text = @"未获取到定位信息,请点击刷新";
    }else{
//        self.label_address.text = [NSString stringWithFormat:@"当前位置:%@",reGeocode.POIName];
//        if (self.isShowAddress) {
            self.strLatitudeMap = CJStringWithFormat(@"%f",location.coordinate.latitude);
            self.strLongitudeMap = CJStringWithFormat(@"%f",location.coordinate.longitude);
        self.strAddress = CJStringWithFormat(@"%@%@%@%@%@" ,StringCheck(reGeocode.province) ,StringCheck(reGeocode.city),StringCheck(reGeocode.district) ,StringCheck(reGeocode.street) ,StringCheck(reGeocode.POIName)) ;  //reGeocode.POIName;
//            self.labAddress.text = reGeocode.POIName;
//            self.labAddress.text = reGeocode.POIName;
//            [CJAlert showStringDismissWithDelay:@"定位成功"];
//        }else{
//
//        }
        [self.locationManager stopUpdatingLocation];
    }
    
}
- (void)dealloc{
    self.locationManager.delegate = nil;
    [self.locationManager stopUpdatingLocation];
}

@end


